﻿using SortProject;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using SortProjectTest.Helpers;
using SortProject.Helpers;


namespace SortProjectTest
{
    
    
    /// <summary>
    ///This is a test class for SortClassTest and is intended
    ///to contain all SortClassTest Unit Tests
    ///</summary>
    [TestClass()]
    public class SortClassTest
    {
        [TestMethod()]
        [Description("This method is fo testing the bubble algorithm")]
        public void SortBubbleTest()
        {

            IEnumerable<int> actual = new int[] {5,3,4,1 };
            IEnumerable<int> result = actual.SortBubble(new TestComparer(),SortProject.Helpers.SortOrder.Ascending);

            List<int> actualList = new List<int>(result);

            IEnumerable<int> exprected = new int[] { 1,3,4,5 };
            List<int> expectedList = new List<int>(exprected);

            CollectionAssert.AreEqual(expectedList,actualList);
        }

        [TestMethod()]
        [Description("This method is fo testing the sort cocktail algorithm")]
        public void SortCocktailTest()
        {

            IEnumerable<int> actual = new int[] { 5, 3, 4, 1 };
            IEnumerable<int> result = actual.SortCocktail(new TestComparer(), SortProject.Helpers.SortOrder.Ascending);

            List<int> actualList = new List<int>(result);

            IEnumerable<int> exprected = new int[] { 1, 3, 4, 5 };
            List<int> expectedList = new List<int>(exprected);

            CollectionAssert.AreEqual(expectedList, actualList);
        }

        [TestMethod()]
        [Description("This method is fo testing the even odd algorithm")]
        public void SortEvenOddTest()
        {
            IEnumerable<int> actual = new int[] { 5, 3, 4, 1 };
            IEnumerable<int> result = actual.SortEvenOdd(new TestComparer(), SortProject.Helpers.SortOrder.Ascending);

            List<int> actualList = new List<int>(result);

            IEnumerable<int> exprected = new int[] { 1, 3, 4, 5 };
            List<int> expectedList = new List<int>(exprected);

            CollectionAssert.AreEqual(expectedList, actualList);
        }

        [TestMethod()]
        [Description("This method is fo testing the sort comb algorithm")]
        public void SortCombTest()
        {
            IEnumerable<int> actual = new int[] { 5, 3, 4, 1 };
            IEnumerable<int> result = actual.SortComb(new TestComparer(), SortProject.Helpers.SortOrder.Ascending);

            List<int> actualList = new List<int>(result);

            IEnumerable<int> exprected = new int[] { 1, 3, 4, 5 };
            List<int> expectedList = new List<int>(exprected);

            CollectionAssert.AreEqual(expectedList, actualList);
        }

        [TestMethod()]
        [Description("This method is fo testing the sort genome algorithm")]
        public void SortGenomeTest()
        {
            IEnumerable<int> actual = new int[] { 5, 3, 4, 1 };
            IEnumerable<int> result = actual.SortGenome(new TestComparer(), SortProject.Helpers.SortOrder.Descending);

            List<int> actualList = new List<int>(result);

            IEnumerable<int> exprected = new int[] { 5,4,3,1 };
            List<int> expectedList = new List<int>(exprected);

            CollectionAssert.AreEqual(expectedList, actualList);
        }

        [TestMethod()]
        [Description("This method is fo testing the sort selection algorithm")]
        public void SortSelectionTest()
        {
            int[] array = new int[] { 5, 3, 4, 1 };
            IEnumerable<int> actual = array;
            IEnumerable<int> result = actual.SortSelection(new TestComparer(), SortProject.Helpers.SortOrder.Descending);

            List<int> actualList = new List<int>(result);

            IEnumerable<int> exprected = new int[] { 5, 4, 3, 1 };
            List<int> expectedList = new List<int>(exprected);

            CollectionAssert.AreEqual(expectedList, actualList); 
        }

        [TestMethod()]
        [Description("This method is fo testing the sort heap algorithm")]
        public void SortHeapTest()
        {
            int[] array = new int[] { 2,1,5,4 };
            IEnumerable<int> actual = array;
            IEnumerable<int> result = actual.SortHeap(new TestComparer(), SortProject.Helpers.SortOrder.Descending);

            List<int> actualList = new List<int>(result);

            IEnumerable<int> exprected = new int[] {5,4,2,1};
            List<int> expectedList = new List<int>(exprected);

            CollectionAssert.AreEqual(expectedList, actualList); 
        }
    }
}